package org.yangspring.samples.mvc.listeners;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.event.SmartApplicationListener;
import org.springframework.stereotype.Component;

/**
 * Created by franklin on 6/27/2017.
 */

@Component
public class SunliuListenerFrankie implements FrankieSmartApplicationListener {

    private static final Logger logger = LoggerFactory.getLogger(SunliuListenerFrankie.class);

    @Override
    public boolean supportsEventType(final Class<? extends ApplicationEvent> eventType) {
        return eventType == ContentEvent.class;
    }

    @Override
    public boolean supportsSourceType(final Class<?> sourceType) {
        return sourceType == String.class;
    }

    @Override
    public void onApplicationEvent(final ApplicationEvent event) {
        logger.warn("\nSun liu After Wang wu Receive new message:\t" + event.getSource());
    }

    @Override
    public int getOrder() {
        return 2;
    }
}
